//
//  ALPS_TSAlbumDTCell.m
//  Alps
//
//  Created by dllo on 16/6/18.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ALPS_TSAlbumDTCell.h"

@implementation ALPS_TSAlbumDTCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        self.smallView = [[UIImageView alloc] init];
        [self.contentView addSubview:_smallView];
        
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_titleLabel];
        
        self.introduceLabel = [[UILabel alloc] init];
        self.introduceLabel.font = [UIFont systemFontOfSize:14];
        self.introduceLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_introduceLabel];
        
        self.playView = [[UIImageView alloc] init];
        self.playView.image = [UIImage imageNamed:@"album_play"];
        [self.contentView addSubview:_playView];
        
        self.playsLabel = [[UILabel alloc] init];
        self.playsLabel.textColor = [UIColor grayColor];
        self.playsLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_playsLabel];
        
        self.bluesView = [[UIImageView alloc] init];
        self.bluesView.image = [UIImage imageNamed:@"album_tracks"];
        [self.contentView addSubview:_bluesView];
        
        self.bluesLabel = [[UILabel alloc] init];
        self.bluesLabel.textColor = [UIColor grayColor];
        [self.bluesLabel sizeToFit];
        self.bluesLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_bluesLabel];

    }

    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    [self.smallView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.contentView).offset(10);
        make.width.equalTo(80);
        make.height.equalTo(80);
        
    }];
    
    [self.titleLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(10);
        make.left.equalTo(self.smallView.right).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
        make.height.equalTo(20);
    }];
    
    [self.introduceLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.bottom).offset(10);
        make.left.equalTo(self.smallView.right).offset(10);
        make.right.equalTo(self.contentView).offset(-10);
        make.height.equalTo(20);
    }];
    
    [self.playView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.introduceLabel.bottom).offset(14);
        make.left.equalTo(self.smallView.right).offset(10);
        make.width.equalTo(10);
        make.height.equalTo(10);
        
    }];
    
    [self.playsLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.introduceLabel.bottom).offset(10);
        make.left.equalTo(self.playView.right).offset(5);
        make.width.equalTo(70);
        make.height.equalTo(20);
        
    }];
    
    
    [self.bluesView makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.introduceLabel.bottom).offset(12);
        make.left.equalTo(self.playsLabel.right).offset(5);
        make.width.equalTo(15);
        make.height.equalTo(15);
    }];
    
    [self.bluesLabel makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.introduceLabel.bottom).offset(10);
        make.left.equalTo(self.bluesView.right).offset(5);
        make.right.equalTo(self.contentView).offset(-10);
        make.height.equalTo(20);
        
    }];
    
}


-(void)setModel:(ALPS_TSearchAllDModel *)model
{
    if (_model != model) {
        _model = model;
        
        [self.smallView sd_setImageWithURL:[NSURL URLWithString:model.cover_path] placeholderImage:[UIImage imageNamed:@"PlaceHolder"]];
        
        self.titleLabel.text = model.title;
        
        if (model.play > 10000) {
            [self.playsLabel sizeToFit];
            self.playsLabel.text = [NSString stringWithFormat:@"%.1f万", model.play / 10000.0];
        }else
        {
            [self.playsLabel sizeToFit];
            self.playsLabel.text = [NSString stringWithFormat:@"%ld", model.play];
        }
        
    }
    self.introduceLabel.text = model.intro;
    self.bluesLabel.text = [NSString stringWithFormat:@"%ld集",model.tracks];
}

- (void)setCollectModel:(ALPS_RightTableCellModel *)collectModel
{
    if (_collectModel != collectModel)
    {
        _collectModel = collectModel;
        
        
        [self.smallView sd_setImageWithURL:[NSURL URLWithString:collectModel.coverLarge] placeholderImage:[UIImage imageNamed:@"PlaceHolder"]];
        
        self.titleLabel.text = collectModel.title;
        
        if (collectModel.playsCounts > 10000)
        {
            [self.playsLabel sizeToFit];
            self.playsLabel.text = [NSString stringWithFormat:@"%.1f万", collectModel.playsCounts / 10000.0];
        }else
        {
            [self.playsLabel sizeToFit];
            self.playsLabel.text = [NSString stringWithFormat:@"%ld", collectModel.playsCounts];
        }
        
    }
//    self.introduceLabel.text = model.intro;
    self.bluesLabel.text = [NSString stringWithFormat:@"%ld集",collectModel.tracks];
    
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
